package cn.lijiguo.concurrency.part1.ch01;

/**
 * ThreadDemo01
 *
 * @author lijiguo
 * @date 2019/12/6 13:59
 */
public class ThreadDemo01 {

    public static void main(String[] args) {
        // 启动两个线程
        new Thread("Task1") {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    try {
                        Thread.sleep(2000L);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName() + ":" + i);
                }
            }
        }.start();

        new Thread("Task2") {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    try {
                        Thread.sleep(2000L);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName() + ":" + i);
                }
            }
        }.start();
    }
}
